﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Odbc;
using System.Configuration;
using System.Data.OleDb;
using System.Data;
using System.Text;

public partial class Order_Order : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            HelloWorldLabel.Text = "Hello, world!";
            OleDbConnection objOLEDB = new OleDbConnection();
            OleDbCommand objOLECmd = new OleDbCommand();
            string _sqlMenu = "select item_id,item_name,item_price from menu_item where item_status = true order by item_name asc ";
            DataTable tabMenuR = new DataTable();


            try
            {
                objOLEDB.ConnectionString = ConfigurationManager.ConnectionStrings["dbConnection"].ConnectionString;
                objOLEDB.Open();
            }
            catch (Exception ex)
            {
                HelloWorldLabel.Text = ex.Message;
            }

            objOLECmd.CommandText = _sqlMenu;
            objOLECmd.Connection = objOLEDB;


            OleDbDataAdapter objOLEAdapt = new OleDbDataAdapter(objOLECmd);
            objOLEAdapt.Fill(tabMenuR);

            StringBuilder sb = new StringBuilder();
            sb.Append("");

            rpt1.DataSource = tabMenuR;
            rpt1.DataBind();

            objOLEDB.Close();

        //    using (OdbcConnection connection = new OdbcConnection(ConfigurationManager.ConnectionStrings["dbConnection"].ConnectionString))
        //    {
        //        connection.Open();
        //        using (OdbcCommand command = new OdbcCommand("SELECT name FROM test_users", connection))
        //        using (OdbcDataReader dr = command.ExecuteReader())
        //        {
        //            while (dr.Read())
        //                Response.Write(dr["name"].ToString() + "<br />");
        //            dr.Close();
        //        }
        //        connection.Close();
        //    }
        
        
        }
        catch (Exception ex)
        {
            HelloWorldLabel.Text = ex.Message;
            Response.Write("An error occured: " + ex.Message);
        }


    }
}